package com.jy.servlet;

import java.io.IOException;
import java.lang.reflect.Method;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class BaseServlet extends HttpServlet {
	
	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String uri=request.getRequestURI();
		int gang=uri.lastIndexOf("/");
		String work=uri.substring(gang+1);
		//方法
		Method m=null;
		try {
			m=this.getClass().getDeclaredMethod(work, HttpServletRequest.class,HttpServletResponse.class);
			//调用方法
			m.invoke(this, request,response);
		} catch (Exception e) {
           e.printStackTrace();
//			System.out.println("找不到此方法");
		}
		
	}
	

}
